<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>  
<!DOCTYPE html>
<html>
<head>
<title>用户管理列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="decorator" content="default" />

    
<%@ include file="/WEB-INF/views/include/bootstrap-table.jsp"%>

<style type="text/css">
.date-field-class{
  width: 100px;
}

</style>
    
</head>

<body class="console-frame-body">
<div class="layui-fluid">
    <div class="layui-row">
        <blockquote class="layui-elem-quote news_search">
		  <form id="searchForm">
		    <sys:message content="${message}"/>
            <div class="layui-inline">
               <input id="officeId" type="hidden" name="officeId" value="${param.officeId}"/>
		       <div class="layui-inline"> 
		                                   登录账号：
		              <div class="layui-input-inline">
		                   <input id="loginName" name="loginName"  class="layui-input search_input" type="text">
		              </div>
		                                     姓名：
		              <div class="layui-input-inline">
		                  <input id="name" name="name"  class="layui-input search_input" type="text">
		              </div>
                   <a  id="btn_search" class="layui-btn search_btn">查询</a>
                   <a  id="btn_reset" onclick="formResetBySearch();" class="layui-btn layui-btn-primary search_btn">重置</a>
              </div>
            </div>
           </form>
        </blockquote>

		<div id="toolbar">
			  <div class="layui-btn-group">
				 <shiro:hasPermission name="sys:user:create">
					  <button type="button" class="layui-btn layui-btn-normal" onclick="gotoView('${ctx}/sys/user/form');">新增</button>
				 </shiro:hasPermission>
				  <shiro:hasPermission name="sys:user:delete">
					  <button type="button" class="layui-btn layui-btn-danger" onclick="batchDelete('sys/user/batchDelete')">批量删除</button>
				 </shiro:hasPermission> 
				 <%-- 
			     <button type="button" class="layui-btn layui-btn-warm" onclick="exportData('${ctx}/sys/user/export',this)">导出</button>--%>
			  </div>
		</div>

	    <table id="table" 
	         data-toggle="table" 
	         data-url="${ctx}/sys/user/userListJson"
	         data-toolbar="#toolbar"
		     data-height="${dataHeight410}" 
		     data-maintain-selected="true" 
		     data-side-pagination="server"
		     data-click-to-select="true" 
		     data-pagination="true" 
		     data-single-select="false"
		     data-id-field="id"
		     data-query-params="doQuery"
		     data-cache="false"
		     data-show-columns="true"
		     data-page-list="${dataPageList}">
		<thead>
			<tr>
				<th data-checkbox="true"></th>
				
				<th data-field="id" data-formatter="operationFormatter" class="date-field-class">操作</th>
				<th data-field="no" data-sortable="true">工号</th> 
				<th data-field="loginName" data-sortable="true">登录账号</th>
				<th data-field="name" data-sortable="true">姓名</th>
				<th data-field="email" data-visible="false">邮箱</th>
				<!-- 	<th data-field="parent.no" data-visible="false">上级工号</th> -->
				<!--<th data-field="parent.name" data-visible="false">上级姓名</th> -->
				<th data-field="orgName" >部门</th>
				<th data-field="loginFlag" data-formatter="loginFlagFormatter">是否允许登录</th>
				<th data-field="myRoleNames">所属角色</th>
				<th data-field="createDate" data-visible="false">创建时间</th>
				<!-- data-sortable="true" 排序 -->
				<!-- data-visible="false" 可以隐藏列 -->
			</tr>
		</thead>
	    </table>
    </div>
</div>

	<script type="text/javascript">
	  var $table = $('#table');
	  $(function () { 
          
	      $("#btn_search").click(function () { 
	              $table.bootstrapTable('refresh'); 
	       }); 
	   }); 
	  
	  //查询函数
	  function doQuery(params) {
		     var loginName_value = $("#loginName").val();
			 var name_value = $("#name").val();
			 
			if(loginName_value != null && loginName_value !=''){
				params.loginName = loginName_value;
			}
			if(name_value != null && name_value !=''){
				params.name = name_value;
			}
			
			var officeId = $("#officeId").val();
			if(officeId != null && officeId !=''){
				params.officeId = officeId;
			}
			
			var userType = '${param.userType}';
			if(userType != null && userType !=''){
				params.userType = userType;
			}
			
		    return params;
	}
	
	/**
	*  操作项  add for lgx  提供查看，修改，删除按钮，如果还有系统按钮，
	*  比如禁用，可在子页面进行自定义函数添加（建议列表操作项按钮不要超过5个）
	*/
	
	var hasView = '${fns:hasPermission("sys:user:view")}';
	var hasEdit = '${fns:hasPermission("sys:user:edit")}';
	var hasDelete = '${fns:hasPermission("sys:user:delete")}';
	
	function operationFormatter(value, row){
		
		var params = "id="+value;
		//查看
		//var html = '<a href="javascript:void(0);" style="padding-right:5px;" onclick="detail(\'sys/role/roleDetail\',\'查看用户\',\''+params+'\')">查看</a>';
		//修改
		var html = '';
		
	    if(hasEdit == 'true'){
	    	html = html + '<a href="javascript:void(0);" class="layui-btn layui-btn-xs" style="padding-right:5px;" onclick="gotoView(\'${ctx}/sys/user/form?'+params+'\');">修改</a>';
		}else{
			html = html + ' <button class="layui-btn layui-btn-disabled layui-btn-xs">修改</button>';
		} 

	    if(hasDelete == 'true'){
			//删除
			html= html +'<a href="javascript:void(0);" class="layui-btn layui-btn-danger layui-btn-xs" onclick="deleteData(\'sys/user/deleteAjax\',\'是否删除数据？\',\''+params+'\')">删除</a>';
	    }else{
	    	html = html + '<button class="layui-btn layui-btn-disabled layui-btn-xs">删除</button>';
	    }

		return html;
	}  
	
	function loginFlagFormatter(value, row){
		if(value == "0"){
			returnvalue = "否";
		}else{
			return value = "是";
		}
		
	}
	</script>
	
	<jsp:include page="/WEB-INF/views/include/pageJs.jsp" />

</body>
</html>